ACLOCAL_AMFLAGS=-I m4

EXTRA_DIST=bootstrap COPYING KEYDB.cfg README.md ChangeLog

SET_FEATURES = @SET_FEATURES@
SET_INCLUDES = -I$(top_srcdir)/src -I$(top_builddir)/src/libaacs

AM_CFLAGS = -std=c99 $(LIBGCRYPT_CFLAGS) $(GPG_ERROR_CFLAGS)
AM_CPPFLAGS = $(SET_FEATURES) $(SET_INCLUDES)
AM_YFLAGS = -d -p libaacs_yy

lib_LTLIBRARIES = libaacs.la
libaacs_la_SOURCES=\
	src/libaacs/aacs.h \
	src/libaacs/aacs.c \
	src/libaacs/cci_data.h \
	src/libaacs/cci.h \
	src/libaacs/cci.c \
	src/libaacs/content_cert.h \
	src/libaacs/content_cert.c \
	src/libaacs/crypto.h \
	src/libaacs/crypto.c \
	src/libaacs/mkb.h \
	src/libaacs/mkb.c \
	src/libaacs/mmc.h \
	src/libaacs/mmc.c \
	src/libaacs/unit_key.h \
	src/libaacs/unit_key.c \
	src/file/dirs.h \
	src/file/file.h \
	src/file/file.c \
	src/file/filesystem.h \
	src/file/filesystem.c \
	src/file/keydbcfg.c \
	src/file/keydbcfg.h \
	src/file/keydb.h \
	src/file/keydbcfg-parser.y \
	src/file/keydbcfg-lexer.l \
	src/file/mmc_device.h \
	src/file/path.h \
	src/util/attributes.h \
	src/util/macro.h \
	src/util/logging.c \
	src/util/logging.h \
	src/util/strutl.c \
	src/util/strutl.h

EXTRA_libaacs_la_SOURCES=\
	src/libaacs/ec.c

if HAVE_DARWIN
libaacs_la_SOURCES+= \
	src/file/dirs_darwin.c \
	src/file/file_posix.c \
	src/file/mmc_device_darwin.c
else
if HAVE_WIN32
libaacs_la_SOURCES+= \
	src/file/dirs_win32.c \
	src/file/file_win32.c \
	src/file/mmc_device_win32.c
else
libaacs_la_SOURCES+= \
	src/file/dirs_xdg.c \
	src/file/file_posix.c \
	src/file/mmc_device_linux.c \
	src/file/path.c
endif
endif

pkginclude_HEADERS = \
	src/libaacs/aacs.h \
	src/file/filesystem.h \
	src/libaacs/aacs-version.h

libaacs_la_LDFLAGS= -no-undefined -version-info $(LT_VERSION_INFO)
libaacs_la_LIBADD = $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = src/libaacs.pc

BUILT_SOURCES = src/libaacs.pc src/libaacs/aacs-version.h src/file/keydbcfg-parser.h src/file/keydbcfg-parser.c src/file/keydbcfg-lexer.c

CLEANFILES = $(BUILT_SOURCES)

clean-lex-yacc:
	-rm -f $(BUILT_SOURCES)

# do not distribute files that should be generated by lex/yacc locally
dist-hook:
	(cd $(distdir) && rm -f $(BUILT_SOURCES))

#
# programs
#

noinst_PROGRAMS = parser_test uk_dump mkb_dump
bin_PROGRAMS = aacs_info

parser_test_SOURCES = \
	src/devtools/parser_test.c \
	src/file/keydbcfg-parser.y \
	src/file/keydbcfg-lexer.l \
	src/util/strutl.c \
	src/util/logging.c
parser_test_CFLAGS = -std=c99

uk_dump_SOURCES = \
	src/devtools/uk_dump.c \
	src/devtools/read_file.h \
	src/libaacs/unit_key.h \
	src/libaacs/unit_key.c \
	src/util/logging.c
uk_dump_CFLAGS = -std=c99

mkb_dump_SOURCES = \
	src/devtools/mkb_dump.c \
	src/devtools/read_file.h \
	src/libaacs/mkb.h \
	src/libaacs/mkb.c \
	src/util/strutl.c \
	src/util/logging.c
mkb_dump_CFLAGS = -std=c99

aacs_info_SOURCES = src/examples/aacs_info.c
aacs_info_CFLAGS = -std=c99
aacs_info_LDADD = libaacs.la
